from primes import PrimeChecker

def ltruncations(n):
    nstr = str(n)
    return [int(nstr[i:]) for i in xrange(len(nstr))]

def rtruncations(n):
    nstr = str(n)
    return [int(nstr[:i+1]) for i in xrange(len(nstr))]

def truncations(n):
    return ltruncations(n) + rtruncations(n)

limit = 1000000

checker = PrimeChecker(limit)

results = []
n = 10

while (len(results) < 11):
    n += 1
    if all(checker.is_prime(x) for x in truncations(n)):
        results.append(n)
        
print results, sum(results)
